﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestBound : MonoBehaviour
{
    public Transform Parent;
    public bool StartBoundl;

    private Vector3 boundPos;
    private Vector3 boundRot;

    // Use this for initialization
    void Start ()
    {
        this.StartBoundl = false;

        this.boundPos = this.transform.position - this.Parent.position;
        this.boundRot = this.transform.localEulerAngles - this.Parent.localEulerAngles;
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            this.StartBoundl = true;
        }
        if (this.StartBoundl)
        {
            //Debug.Log(this.Parent.transform.eulerAngles);
            this.transform.RotateAround(this.Parent.transform.position, this.Parent.right, this.Parent.localEulerAngles.x);
            this.transform.RotateAround(this.Parent.transform.position, this.Parent.up, this.Parent.localEulerAngles.y);
            this.transform.RotateAround(this.Parent.transform.position, this.Parent.forward, this.Parent.localEulerAngles.z);
            this.transform.localEulerAngles = this.boundRot + this.Parent.localEulerAngles;
            this.StartBoundl = false;
            Debug.Log("position :" + this.Parent.GetChild(0).position);
            Debug.Log("localEulerAngles :" +this.Parent.GetChild(0).eulerAngles);
        }

    }
}
